630D - Hexagons - CodeForces Solution


math *1100

Please click on ads to support us..

Python Code:

import math as mt
from collections import defaultdict,deque
from bisect import bisect_left as b_l
from bisect import bisect_right as b_r
import sys

mod=10**9+7

n=int(input())
if(n==0):
    print(1)
else:
    print((((n*(n+1))//2)*6)+1)

C++ Code:

/**
 It falls to me to inform you that this one is in the bag
 **/
//========================================================================================//
// Name        : Mohamed Ahmed Galhoum
// Cf_Handle   : ShAdoW_77
// Date        : 2023
// Goal        : reach Master || GrandMaster ("one Day I will say (I did it !!)")
/// I won’t run away anymore…
/// I won’t go back on my word…
/// That is my Ninja way !
/// Microsoft next year insha-alahh (2024 || Max_In : (2025) ) -- (2026||2027) in ICPC Insha-allah this is For Remember :) xD !
//========================================================================================//
/*
 STAY ORGANIZED
 CHANGE YOUR APPROACH
 BE CONFIDENT
 */
// =======================================================================================//
/*
 صباح كل
 السماء زرقة على التحية القى
 المسافرة الحمامات بعض كل
 .كذلك صعبا ليس سهلا ليس ما بان نفسى اذكر و
 */
// =======================================================================================//
#include<bits/stdc++.h>
using namespace std;
#define Galhoum ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define  ll long long
#define endl "\n";
using str = string;
const int MAX = 1e5 + 10;
const int mod1 = 1e9 + 7;
const ll llOO = 0x3f3f3f3f3f3f3f3f;
#define TC_Galhoum(t) while (t--)
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<char, char> pairs;
#define F first
#define S second
#define ld long double
#define maxz(x, y) x = max(x, y)
#define minz(x, y) x = min(x, y)
#define  loop(n)     for(int i=0; i<n; i++)
#define ll_loop(n)   for(ll i=0;i<n;i++)
#define each(a, x)   for (auto& a : (x))
#define sz(a) ((int) (a).size())
#define  loop1(n)     for(int i=1; i<=n; i++)
#define  loopj(n)    for(int j=0; j<n; j++)
#define  loop_(i,j)  for(int i=0,j=1;i<n,j<n;i++,j++)
#define loop_1(i, a, b) for (int i = a; i < b; i++)
#define  YES         cout << "YES"<<endl;
#define  NO          cout << "NO" << endl;
#define alls(a)  a.begin(),a.end()
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
#define all(v)                ((v).begin()), ((v).end());
#define Formula(start,end) (ll)(((1.0*(end-start+1)))/2*(start+end));
const double EPS = 1e-9;
char dcmp(double a, double b) {
	return fabs(a - b) < EPS ? '=' : a > b ? '>' : '<';
}
long long powers[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096,
		8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152,
		4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456,
		536870912, 1073741824, 2147483648 };
// ====================================== My Solution ==================================== //
inline int end() {
	int N;
	cin >> N;
	return N;
}
inline long long endll() {
	ll N;
	cin >> N;
	return N;
}
inline string read() {
	str st;
	cin >> st;
	return st;
}
inline double dou() {
	double N;
	cin >> N;
	return N;
}
inline char chend() {
	char c;
	cin >> c;
	return c;
}
void My_Ninja_Way(){
	ll N = endll();
	cout <<  ((3 * N)*(N+1))+1 << endl;
}
// ======================================================================================== //
int main() {
// Opportunities don't happen. You Creat Them //
//#ifndef ONLINE_JUDGE
//	freopen("Input.txt", "r", stdin);
//	freopen("Output.txt", "w", stdout);
//#endif
	Galhoum
	int t = 1;
	TC_Galhoum(t) {
		My_Ninja_Way();
	}
	cerr << "Galhoum here" << endl;
	return 0;
}
// ======================================================================================== //
/*
 * Think twice, code once
 * Think of different approaches to tackle a problem: write them down.
 * Think of different views of the problem. don't look from only one side.
 * don't get stuck in one approach.
 * common mistakes: over_flow
 *                  - out_of_bound index
 *                  -infinite loop
 *                  -corner cases
 *                  -duplication counting.
 */
// ======================================================================================== //


Comments

Submit
0 Comments
More Questions

1726C - Jatayu's Balanced Bracket Sequence
1726A - Mainak and Array
1613C - Poisoned Dagger
475B - Strongly Connected City
652B - z-sort
124B - Permutations
1496C - Diamond Miner
680B - Bear and Finding Criminals
1036E - Covered Points
1015D - Walking Between Houses
155B - Combination
1531A - Зингер | color
1678A - Tokitsukaze and All Zero Sequence
896A - Nephren gives a riddle
761A - Dasha and Stairs
1728B - Best Permutation
1728A - Colored Balls Revisited
276B - Little Girl and Game
1181A - Chunga-Changa
1728C - Digital Logarithm
1728D - Letter Picking
792B - Counting-out Rhyme
1195A - Drinks Choosing
5D - Follow Traffic Rules
1272A - Three Friends
1632D - New Year Concert
1400D - Zigzags
716C - Plus and Square Root
412A - Poster
844B - Rectangles